//
//  FBtModel.m
//  JwPack
//
//  Created by 陈警卫 on 2025/7/21.
//

#import "FBtModel.h"

@implementation FBtModel

@end

@implementation FBtPeriModel

/// 外设Uuid
- (NSString *)periUuid {
    return self.peri.identifier.UUIDString;
}

/// 外设name
- (NSString *)periName {
    return self.peri.name;
}

/// 外设制造商数据
- (NSData *)periMaferData {
    NSData *maferData = [self.advDict objectForKey:CBAdvertisementDataManufacturerDataKey];
    return maferData;
}


// timer

- (void)startTimer {
    [self endTimer];
    if (self.timeout > 0) {
        __weak typeof(self) wself = self;
        self.timer = [NSTimer scheduledTimerWithTimeInterval:self.timeout repeats:NO block:^(NSTimer * _Nonnull timer) {
            [wself timeAction];
        }];
    }
}

- (void)timeAction {
    if (self.didTimerAction) {
        NSError *error = [NSError errorWithDomain:@"连接超时" code:1 userInfo:nil];
        self.didTimerAction(error);
    }
    [self endTimer];
}

- (void)endTimer {
    [self.timer invalidate];
    self.timer = nil;
}



@end

